using System;
using Microsoft.Practices.ObjectBuilder;

namespace WCSFContrib.Extensions.CompositeWeb.Tests.Mocks
{
	public class MockBuilderContext : IBuilderContext
	{
		IReadWriteLocator locator = new Locator();
		BuilderStrategyChain chain = new BuilderStrategyChain();
		PolicyList policies = new PolicyList();

		public MockBuilderContext(params IBuilderStrategy[] strategies)
		{
			if (strategies == null)
			{
				throw new ArgumentNullException("strategies");
			}

			foreach (IBuilderStrategy strategy in strategies)
				chain.Add(strategy);
		}

		public IBuilderStrategy HeadOfChain
		{
			get { return chain.Head; }
		}

		public IBuilderStrategy GetNextInChain(IBuilderStrategy currentStrategy)
		{
			return chain.GetNext(currentStrategy);
		}

		public IReadWriteLocator Locator
		{
			get { return locator; }
		}

		public PolicyList Policies
		{
			get { return policies; }
		}
	}
}
